
var _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(t) {
  return typeof t;
} : function(t) {
  return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
}, _tools = require("../../utils/tools"), _util = require("../../utils/util");

function _defineProperty(t, e, o) {
  return e in t ? Object.defineProperty(t, e, {
      value: o,
      enumerable: !0,
      configurable: !0,
      writable: !0
  }) : t[e] = o, t;
}

var g, pages, app = getApp(), page = app.page, request = app.util.request, route = app.route,toast = app.toast;;
// member/index/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    userInfo: {},
    equity: [],
    nav: 0
  },
  
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    g = this;
    let userInfo = wx.getStorageSync("userInfo")
      g.setData({
        userInfo
      })
      request({
        url: "Openid",
        showLoading: !1,
        data: {
          user_id: g.data.userInfo.id
        },
        success: function(t) {
          // let equity = [
          //   {
          //     name: "法律文本下载",
          //     num: t.contract_download == 'all' ? '全部' : t.contract_download,
          //     unit: t.contract_download == 'all' ? '' : "次"
          //   },
          //   {
          //     name: "法律大讲堂",
          //     num: t.law_lecture == 'all' ? '全部' : t.law_lecture,
          //     unit: t.law_lecture == 'all' ? '' : "次"
          //   },
          //   {
          //     name: "小咚在线咨询累积权益",
          //     num: t.online_visit_num_all > 1000 ? '无限' : t.online_visit_num_all,
          //     unit: "次"
          //   },
          //   {
          //     name: "律师电话咨询",
          //     num: t.phone_visit_num_all > 1000 ? '无限' : t.phone_visit_num_all,
          //     unit: "次"
          //   },
          //   {
          //     name: "视频对话咨询",
          //     num: t.face_visit_num_all > 1000 ? '无限' : t.face_visit_num_all,
          //     unit: "次"
          //   },
          //   {
          //     name: "律师上门服务",
          //     num: t.door_visit_num_all > 1000 ? '无限' : t.door_visit_num_all,
          //     unit: "次"
          //   },
          //   {
          //     name: "设备折扣",
          //     num: t.device_discount > 1000 ? '无限' : t.device_discount,
          //     unit: "折"
          //   },
          //   {
          //     name: "单独付费折扣",
          //     num: t.only_discount > 1000 ? '无限' : t.only_discount,
          //     unit: "折"
          //   }
          // ]
          // if(t.legal_forum){
          //   equity.push({
          //     name: t.legal_forum,
          //     num: false,
          //     unit: false
          //   })
          // }
          // if(t.text_download){
          //   equity.push({
          //     name: t.text_download,
          //     num: false,
          //     unit: false
          //   })
          // }
          // if(t.dong){
          //   equity.push({
          //     name: t.dong,
          //     num: false,
          //     unit: false
          //   })
          // }
          g.setData({
            userInfo: t,
            //equity
          })
        }
      })
      request({
        url: "MemberShipEquity",
        showLoading: !1,
        data: {
          user_id: g.data.userInfo.id
        },
        success: function(t) {
            let equity = []
            for(let i = 0;i < t.length;i++){
              equity.push({
                name: t[i],
                num: false,
                unit: false
              })
            }
            g.setData({
              equity
            })
        }
      })
  },
  changeNav(e){
    let nav = e.currentTarget.dataset.index
    let equity = []
    let t = g.data.userInfo
    if(nav == 0){
      equity = [
        {
          name: "法律文本下载",
          num: t.contract_download == 'all' ? '全部' : t.contract_download,
          unit: t.contract_download == 'all' ? '' : "次"
        },
        {
          name: "法律大讲堂",
          num: t.law_lecture == 'all' ? '全部' : t.law_lecture,
          unit: t.law_lecture == 'all' ? '' : "次"
        },
        {
          name: "小咚在线咨询累积权益",
          num: t.online_visit_num_all > 1000 ? '无限' : t.online_visit_num_all,
          unit: "次"
        },
       
        
        {
          name: "律师电话咨询",
          num: t.phone_visit_num_all > 1000 ? '无限' : t.phone_visit_num_all,
          unit: "次"
        },
        {
          name: "视频对话咨询",
          num: t.face_visit_num_all > 1000 ? '无限' : t.face_visit_num_all,
          unit: "次"
        },
        {
          name: "律师上门服务",
          num: t.door_visit_num_all > 1000 ? '无限' : t.door_visit_num_all,
          unit: "次"
        },
        {
          name: "设备折扣",
          num: t.device_discount > 1000 ? '无限' : t.device_discount,
          unit: "折"
        },
        {
          name: "单独付费折扣",
          num: t.only_discount > 1000 ? '无限' : t.only_discount,
          unit: "折"
        }
      ]
    } else {
      equity = [
        {
          name: "法律文本下载",
          num: t.contract_download == 'all' ? '全部' : t.contract_download,
          unit: t.contract_download == 'all' ? '' : "次"
        },
        {
          name: "法律大讲堂",
          num: t.law_lecture == 'all' ? '全部' : t.law_lecture,
          unit:  t.law_lecture == 'all' ? '' : "次"
        },
        
        {
          name: "小咚在线咨询累积权益",
          num: t.online_visit_num > 1000 ? '无限' : t.online_visit_num,
          unit: "次"
        },
        
        {
          name: "律师电话咨询",
          num: t.phone_visit_num > 1000 ? '无限' : t.phone_visit_num,
          unit: "次"
        },
        {
          name: "视频对话咨询",
          num: t.face_visit_num > 1000 ? '无限' : t.face_visit_num,
          unit: "次"
        },
        {
          name: "律师上门服务",
          num: t.door_visit_num > 1000 ? '无限' : t.door_visit_num,
          unit: "次"
        },
        {
          name: "设备折扣",
          num: t.device_discount > 1000 ? '无限' : t.device_discount,
          unit: "折"
        },
        {
          name: "单独付费折扣",
          num: t.only_discount > 1000 ? '无限' : t.only_discount,
          unit: "折"
        }
      ]
    }
    if(t.legal_forum){
      equity.push({
        name: t.legal_forum,
        num: false,
        unit: false
      })
    }
    if(t.text_download){
      equity.push({
        name: t.text_download,
        num: false,
        unit: false
      })
    }
    if(t.dong){
      equity.push({
        name: t.dong,
        num: false,
        unit: false
      })
    }
    g.setData({
      nav,
      equity
    })
  },
  
 
  
  submit(){
   wx.navigateTo({
     url: '/member/index/index',
   })
  
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})